#ifndef CSPRITE_H
#define CSPRITE_H

#include "../include/constantes.h"
class CSpriteAnimation;

struct SDL_Surface;
struct SDL_Rect;

//**************************
//Manage interactions between the animation and the screen
//**************************
class CSprite
{
    private:
        int m_iX;	//Where the sprite is on the abscissa

        int m_iY;	//Where the sprite is on the ordinary

        int m_iDisplayedFrame;	//Number of the displayed frame

        int m_iRemainingLoops;  //Number of loops to do

        bool m_bAnimating;	//True if the sprite is currently animating, otherwise false

        bool m_bDrawn;	//True if the sprite has been drawn once on the screen, otherwise false

        bool m_bReverseAnim; //True if the animation has to be drawn in reverse order

        long m_lLastUpdate;	//Time when the sprite has been last updated

        float m_fSpeed;	//Speed of the animation

        SDL_Surface * m_Screen;	//Screen surface

        CSpriteAnimation * m_SpriteAnimation;	//A pointer toward the animations


    public:
        //**************************
        //Description : Constructor
        //Parameters : None
        //Note : None
        //**************************
        CSprite();

        //**************************
        //Description : Constructor
        //Parameters : The animation for the sprite, and a pointer on the screen
        //Note : None
        //**************************
        CSprite(CSpriteAnimation * _Animation, SDL_Surface * _Screen);

        //**************************
        //Description : Copy Constructor
        //Parameters : A CSprite
        //Note : None
        //**************************
        CSprite(CSprite & _Sprite);

        //**************************
        //Description : Destructor
        //Parameters : None
        //Note : None
        //**************************
        ~CSprite();

        //**************************
        //Description : Init the sprite
        //Parameters : The animation for the sprite, and a pointer on the screen
        //Return Value : None
        //Note : None
        //**************************
        void InitSprite(CSpriteAnimation * _Animation, SDL_Surface * _Screen);

        //**************************
        //Description : Return if the animation has been built or not
        //Parameters : None
        //Return Value : True if the animation is built, otherwise false
        //Note : None
        //**************************
        bool IsBuilt() const;

        //**************************
        //Description : Return if the animation is at the end or not
        //Parameters : None
        //Return Value : True if the animation is at the end, otherwise false
        //Note : The animation is at the end if there is no more loops to do and if the animation is at its last frame
        //      or, if the remaining loops are negetives (unlimited), if the animation is at its last frame
        //**************************
        bool EndAnimation() const;

        //**************************
        //Description : Draw the sprite on the screen
        //Parameters : The area of the sprite that we display
        //Return Value : None
        //Note : None
        //**************************
        void Draw(SDL_Rect * _AreaDisplayed = NULL);

        //**************************
        //Description : Draw the sprite on the screen
        //Parameters : the position in the screen where the sprite has to be drawn
        //              and The area of the sprite that we display
        //Return Value : None
        //Note : None
        //**************************
        void Draw(SDL_Rect * _Dest, SDL_Rect * _AreaDisplayed);

        //**************************
        //Description : Set the number of the displayed frame to _iNewFramei
        //Parameters : The number for the new frame
        //Return Value : None
        //Note : None
        //**************************
        void SetDisplayedFrame(int _iNewFrame);

        //**************************
        //Description : Return the number of the displayed frame
        //Parameters : None
        //Return Value : The number of the displayed frame
        //Note : None
        //**************************
        int GetDisplayedFrame() const;

        //**************************
        //Description : Set the speed of the animation with _fNewSpeed
        //Parameters : The new speed
        //Return Value : None
        //Note : None
        //**************************
        void SetSpeed(float _fNewSpeed);

        //**************************
        //Description : Return the speed of the animation
        //Parameters : None
        //Return Value : The speed
        //Note : None
        //**************************
        float GetSpeed() const;

        //**************************
        //Description : Toggle the animation
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void ToggleAnim();

        //**************************
        //Description : Start the animation
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void StartAnim();

        //**************************
        //Description : Stop the animation
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void StopAnim();

        //**************************
        //Description : Rewind the animation
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void RewindAnim();

        //**************************
        //Description : Set m_bReverseAnim
        //Parameters : a boolean
        //Return Value : None
        //Note : None
        //**************************
        void ReverseAnim(bool _vReverse);

        //**************************
        //Description : Change m_iX by adding m_iValue
        //Parameters : the value to add to m_iX
        //Return Value : None
        //Note : None
        //**************************
        void XAdd(int _iValue);

        //**************************
        //Description : Change m_iY by adding m_iValue
        //Parameters : the value to add to m_iY
        //Return Value : None
        //Note : None
        //**************************
        void YAdd(int _iValue);

        //**************************
        //Description : Change m_iX to m_iValue
        //Parameters : the new value of m_iX
        //Return Value : None
        //Note : None
        //**************************
        void SetX(int _iValue);

        //**************************
        //Description : Change m_iY to m_iValue
        //Parameters : the new value of m_iY
        //Return Value : None
        //Note : None
        //**************************
        void SetY(int _iValue);

        //**************************
        //Description : Change m_iX to m_iXValue and m_iY to m_iYValue
        //Parameters : the new value of m_iX and m_iY
        //Return Value : None
        //Note : None
        //**************************
        void Set(int _iXValue, int _iYValue);

        //**************************
        //Description : Return the width of the animation
        //Parameters : None
        //Return Value : The width of the animation
        //Note : None
        //**************************
        int GetWidth() const;

        //**************************
        //Description : Return the width of the animation
        //Parameters : None
        //Return Value : The width of the animation
        //Note : None
        //**************************
        int GetHeight() const;
};
#endif
